package dimension.starry.mixin;

import dimension.starry.event.Events;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Environment(EnvType.CLIENT)
@Mixin(value = InGameHud.class, priority = 1001)
public class InGameHudMixin {

    @Redirect(
        method = "render",
        at = @At(value = "INVOKE",
            target = "Lnet/minecraft/client/gui/hud/InGameHud;renderStatusBars(Lnet/minecraft/client/gui/DrawContext;)V")
    )
    public void onRenderStatusBars(InGameHud instance, DrawContext context) {
        Events.HUD_RENDER_EVENT.invoker().onHudRender(context, instance);
    }

    @Redirect(
        method = "renderExperienceBar",
        at = @At(value = "INVOKE",
            target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;IIIZ)I")
    )
    public int onRenderExperienceBarText(
        DrawContext instance, TextRenderer textRenderer, String text, int x, int y, int color, boolean shadow
    ) {
        return 0;
    }

}
